/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.daten;


/**
 * @author Michael Nitsche
 */
public class MN {

	public static boolean oder(Object das, Object... gleich) {
		for(Object o : gleich)
			if(das.equals(o))
				return true;
		return false;
	}

	public static Object[]  o(Object... o)    { return o; }
	public static String[]  s(String... s)    { return s; }
	public static Integer[] i(Integer... i)   { return i; }
//	public static char[]   c(char... c)     { return c; }

	public static boolean istGefuellt(String test) {
		return test!=null && test.length()>0;
	}

	public static <T> T[]  t(T... t) {
		return t;
	}

	public static <T> T beiNull(T objekt, T bei_null) {
		return objekt==null ? bei_null : objekt;
	}

	public static boolean istTrue(Boolean b) {
		return b!=null && b;
	}

	public static boolean istNull(Object... oa) {
		for(Object o : oa)
			if(o != null)
				return false;
		return true;
	}

	public static boolean istGleich(Object o1, Object o2) {
		if(o1==null && o2==null)
			return true;
		if(o1==null || o2==null)
			return false;
		return o1.equals(o2);
	}

}
